<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>同时请求多个数据</title>
</head>
<body>
<div id="app">

</div>

<script src="../../../../js/axios.js"></script>
<script type="module">
    import {createApp, onMounted} from "../../../../js/vue.esm-browser.js";

    let app = createApp({
        setup() {
            function getRequest() {
                return axios.get(
                    "https://www.httpbin.org/get",
                    {
                        params: {
                            name: "abcque",
                            age: 18,
                            gender: "M",
                            method: "get",
                        }
                    }
                );

            }

            function postRequest() {
                return axios.post(
                    "https://www.httpbin.org/post",
                    {
                        name: "abcque",
                        age: 18,
                        gender: "M",
                        method: "post",
                    }
                );
            }

            function multiRequest() {
                Promise.all([getRequest(), postRequest()])
                    .then(function ([get, post]) {
                        console.log(get);
                        console.log(post);
                    })
            }

            onMounted(() => {
                multiRequest()
            })

            return {}
        }
    })

    app.mount("#app")
</script>
</body>
</html>